package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @author liyang
 * @version 1.0
 * @package io
 * @file Test2.java
 * @description
 * @time 2024-03-21 10:34
 */
public class Test2 {
    public static void main(String[] args) throws IOException {
        //覆盖模式
        //FileOutputStream fos = new FileOutputStream("./note.txt");
        //追加模式
        FileOutputStream fos = new FileOutputStream("./note.txt",true);
        Scanner scn = new Scanner(System.in);
        System.out.println("输入exit则退出");
        while (true){
            String line = scn.nextLine();
            if("exit".equalsIgnoreCase((line))){
                break;
            }
            byte[] data = line.getBytes(StandardCharsets.UTF_8);
            fos.write(data);
        }
        System.out.println("输入结束");
        fos.close();
    }
}
